package com.jic.market.impl;

import java.lang.Long;
import java.util.List;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.market.entity.LotteryAwards;
import com.jic.market.mapper.LotteryAwardsMapper;
import com.jic.market.service.LotteryAwardsService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 抽奖活动奖品关联表
 * @author : 
 * @email : 
 * @since : 2020-03-03 03:05:46
 * @version : v1.0.0
 */
@Service
public class LotteryAwardsServiceImpl implements LotteryAwardsService{

    @Autowired
    private LotteryAwardsMapper lotteryAwardsMapper;

    @Override
    public long insert(LotteryAwards lotteryAwards) {
        long flag = lotteryAwardsMapper.insert(lotteryAwards);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return lotteryAwardsMapper.delete(id);
    }

    @Override
    public long update(LotteryAwards lotteryAwards) {
        return lotteryAwardsMapper.update(lotteryAwards);
    }

    @Override
    public LotteryAwards queryByPrimaryKey(Long id){
        return lotteryAwardsMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<LotteryAwards> query(LotteryAwards lotteryAwards){
        return lotteryAwardsMapper.query(lotteryAwards);
    }

    @Override
    public PageResult<LotteryAwards> queryPage(LotteryAwards lotteryAwards, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<LotteryAwards> list = lotteryAwardsMapper.queryPage(startIndex, pageQuery.getLimit(), lotteryAwards);
        long count = lotteryAwardsMapper.queryPageCount(lotteryAwards);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}